//
//  YCLoopView.m
//  KuaiYi
//
//  Created by 刘胤辰 on 16/7/5.
//  Copyright © 2016年 it.com. All rights reserved.
//

#define kBannersUrl @"http://iosapi.itcast.cn/banners.json.php"

#import "YCLoopView.h"
#import "NetWorkTool.h"

@interface YCLoopView()<UICollectionViewDataSource,UICollectionViewDelegate>

@end

@implementation YCLoopView

-(instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout{
    
    self=[super initWithFrame:frame collectionViewLayout:layout];
    
    [self registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellID2"];
    
    self.delegate=self;
    self.dataSource=self;
    
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
        [self loadData];
    });
    
    return self;
}

-(void)loadData{
    
    NSString *urlString = kBannersUrl;
    NSDictionary *paramDic = @{
                               @"login_token":@"985c96ce43bb5ef69de3e1ad8afaa83f",
                               @"page_size":@10,
                               @"page":@1};
    
    
    [self loadUrl:urlString params:paramDic];
}

-(void)loadUrl:(NSString *)urlString
        params:(NSDictionary *)paramDic{
    
    
    
    [[NetWorkTool shareManager] POST_RequestWithUrlString:urlString parmas:paramDic successBloock:^(id responseObject) {
        
        NSDictionary *dict=(NSDictionary *)responseObject;
        NSDictionary *dict2=(NSDictionary *)dict[@"data"];
        NSArray *dict3=(NSArray *)dict2[@"banners"];
        
        
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"error = %@",error);
    
    }];
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 0;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    return nil;
}
@end
